package com.mhc.suzuki.config;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;

/**
 * Created by HW
 * on 2017/9/11 14:25.
 * websocket 获取 httpSession 配置类
*/


@Slf4j
public class GetHttpSessionConfigurator extends ServerEndpointConfig.Configurator{

    @Override
    public void modifyHandshake(ServerEndpointConfig sec,
                                HandshakeRequest request, HandshakeResponse response) {
            try {
                HttpSession httpSession=(HttpSession) request.getHttpSession();
                sec.getUserProperties().put(HttpSession.class.getName(),httpSession);
            } catch (Exception e){
                log.info("获取httpSession有误");
            }
    }

}
